<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>库房出库单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8"/>
    <link rel="stylesheet" href="../../css/font.css">
    <link rel="stylesheet" href="../../css/xadmin.css">
    <link rel="stylesheet" href="../../lib/layui/css/layui.css" media="all">
    <script src="../../lib/layui/layui.js" charset="utf-8"></script>
    <script src="../../js/jquery.min.js"></script>
    <script type="text/javascript" src="../../js/xadmin.js"></script>
    <script src="../../js/MyCommon.js"></script>
</head>
<body>




<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form ">
                        <div class="x-nav">
                          <span class="layui-breadcrumb">
                            <a href="">首页</a>
                            <a><cite>库房出库单/Warehouse delivery order</cite></a>
                          </span>
                            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
                               onclick="location.reload()" title="刷新">
                                <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
                        </div>
                        <br>

                        <div class="layui-inline">
                            <div class="layui-input-inline ">
                                <input type="text" name="documentNo" id="documentNo" placeholder="请输入单据号"
                                       class="layui-input">
                            </div>
                        </div>

                        <!--<div class="layui-inline">
                            <label class="layui-form-label">开始时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="startTime" id="startTime" readonly="readonly" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">结束时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="endTime" id="endTime" readonly="readonly" autocomplete="off" class="layui-input">
                            </div>
                        </div>-->

                        <div class="layui-inline">
                            <div class="layui-input-inline ">
                                <button type="button" class="layui-btn layui-btn-warm" id="sreach"><span class="layui-icon">&#xe615;</span>查询</button>
                            </div>
                        </div>
                        <!--<div class="layui-inline">
                            <div class="layui-input-inline ">
                                <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                            </div>
                        </div>-->
                    </form>
                </div>
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-hide" id="warTable" lay-filter="Monitor"></table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>

<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-radius layui-btn-danger layui-btn-sm" lay-event="batchAdd">添加出库单</button>
    </div>
</script>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>

<script>
    $(function () {
        loadpage();
    })

    function loadpage() {
        var documentNo = $("#documentNo").val();
        // console.log("第一次打印："+documentNo);
        renderdata(documentNo);
    }

    function renderdata(documentNo) {
        // console.log("第二次打印："+documentNo);
        requestAjax("/JT90/DrugsExportController/queryDrugsExport", "get", "json", "documentNo="+documentNo, function (res) {

            var data = res.data;
            render(data);
        })
    }
    function render(data) {
        layui.use(['table', 'layer', 'form', 'laypage', 'laydate'], function () {
            var table = layui.table;
            var layer = layui.layer;
            var form = layui.form;
            var laypage = layui.laypage;
            var laydate = layui.laydate;
            /*//绑定时间选择器
            laydate.render({
                elem: '#startTime'
            })

            laydate.render({
                elem: '#endTime'
            })*/
            var tableIns =table.render({
                elem: '#warTable'
                , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
                ,data:data
                , defaultToolbar: ['exports']
                , title: '出库单据表'
                , cols: [[
                    {field: 'documentNo', title: '单据号', align: "center"}
                    , {field: 'outOfWarehouse', title: '出库方', align: "center"}
                    , {field: 'receivingOffice', title: '接收处', align: "center"}
                    , {field: 'entryPerson', title: '录入人', align: "center"}
                    , {field: 'entryTime', title: '录入时间', align: "center"}
                    , {field: 'dictionaryData', title: '单据状态', style:"color:red;",align: "center"}
                    , {field: 'remarks', title: '备注', align: "center"}
                    , {fixed: 'right', title: '操作', toolbar: '#barDemo', align: "center"}
                ]]
                , page: {
                    count: 100
                    , layout: ['limit', 'count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
                    , groups: 5 //只显示 1 个连续页码
                    , first: '首页'//不显示首页
                    , last: '尾页' //不显示尾页
                    , limit: 5
                    , limits: [5, 10, 15, 20]
                    , theme: '#44cc33'
                    , jump: function (obj) {
                        console.log(obj)
                    }
                }

            });
            //监听行工具事件
            table.on('tool(Monitor)', function (obj) {
                var data = obj.data;
                var documentNo = data.documentNo;
                console.log(documentNo)
                if (obj.event === 'del') {
                    layer.confirm('确定删除吗?', {icon: 4}, function (index) {
                        requestAjax("/JT90/DrugsExportController/delDrugsExport", "get", "json", "documentNo=" + documentNo, function (res) {
                            if (res.success) {
                                layer.msg('删除成功！', {icon: 6})
                                location.reload();
                            } else {
                                layer.msg('删除失败！', {icon: 5});
                            }
                        })
                        obj.del();
                        layer.close(index);
                    });
                }
            });

            //头工具栏事件
            table.on('toolbar(Monitor)', function(obj){
                if(obj.event==="batchAdd"){
                    //编辑入库单
                    layer.open({
                        type:2,
                        title:['添加出库单','color:#fff;background-color:#01AAED;'],
                        content:'5.4add.html',
                        area:['600px','400px']
                    })
                };
            });


        });
    }
    //监听查询
    $("#sreach").click(function () {
        loadpage();
    });
</script>
</html>
